/**
 * 找出字符串中第一次只出现一次的字母
 * @returns 
 */
 function firstAppear(str:string){
    const res = str.split("")
    var obj:any = {},
    len = str.length;
    for (var i = 0; i < len; i++) {
        if (obj[str[i]]) {
            obj[str[i]]++;
        } else {
            obj[str[i]] = 1;
        }
    }
    for (var prop in obj) {
        if (obj[prop] == 1) {
            return prop;
        }
    }
}

console.log(firstAppear("abacdefeg"));
